package com.xxx.networkdisksystem.controller;


import com.xxx.networkdisksystem.pojo.Customeraccounts;
import com.xxx.networkdisksystem.service.CustomeraccountsService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author George
 * @since 2023-11-05
 */
@Api(tags = "客户控制")
@CrossOrigin
@RestController
@RequestMapping("/customeraccounts")
public class CustomeraccountsController {

    @Resource
    private CustomeraccountsService customeraccountsService;

    public boolean saveCustomerAccounts(){
        Customeraccounts customeraccounts = new Customeraccounts();
        customeraccounts.setName("George");
        customeraccounts.setUser("admin1");
        customeraccounts.setPassword("admin");
        return customeraccountsService.save(customeraccounts);
    }

    public boolean removeByIdCustomerAccounts(){
        return customeraccountsService.removeById("64576416d7b283ff0dec64349ac8787f");
    }

    public boolean updateByIdCustomerAccounts() {
        // 1. 根据主键 ID 查询出需要修改的记录。
        Customeraccounts customer = customeraccountsService.getById("64576416d7b283ff0dec64349ac8787f");
        // 2. 修改该记录的字段值。
        customer.setName("George222");
        customer.setUser("admin222");
        // 3. 调用 update 方法将修改后的记录更新到数据库中。
        return customeraccountsService.updateById(customer);
    }


}

